package study.mybatis.support.utils;

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.plugin.Invocation;

import java.lang.reflect.Method;
import java.util.Arrays;

@Slf4j
public class PluginUtils {

    public static void printInvocation(Invocation invocation) {
        Object target = invocation.getTarget();
        log.info(">>>>>> target= {}", target.getClass().getName());
        Method method = invocation.getMethod();
        log.info(">>>>>> method= {}", method.getName());
        Object[] args = invocation.getArgs();
        log.info(">>>>>> arg count= {}", args.length);
        Arrays.stream(args).forEach(e -> {
            if (e != null) {
                log.info(">>>>>> args= {}", e.getClass().getName());
            } else {
                log.info(">>>>>> args=");
            }
        });
    }
}
